package com.laysonx.easy.invoke.support;

import com.laysonx.easy.invoke.core.EasyInvokePostProcessor;
import lombok.Data;

import java.util.HashSet;
import java.util.Set;

@Data
public class InvokeMonitor {

    private String domain = "";

    private Set<EasyInvokePostProcessor> postProcessors = new HashSet<>();

    public void addPostProcessor(EasyInvokePostProcessor processor) {
        postProcessors.add(processor);
    }

    public void postProcessor(InvokeBody invokeBody, InvokeResult invokeResult) {
        if (postProcessors != null && postProcessors.size() != 0) {
            for (EasyInvokePostProcessor processor : postProcessors) {
                processor.postProcessorAfterInvoke(invokeBody, invokeResult);
            }
        }
    }

    public String getDomain(){
        if(!domain.equals("")){
            return "/"+ domain;
        }else{
            return "";
        }
    }

}
